/* 
 * bessel.h
 * 
 * Kirankumar R. Hiremath
 * Applied Analysis and Mathematical Physics Group
 * University of Twente, Department of Applied Mathematics 
 * P.O. Box 217, 7500AE Enschede, The Netherlands
 * (2004)
 *
 * email: k.r.hiremath@ieee.org
 */

/*
   Description: 
  1.This is a C++ library (part of it based on FORTRAN) to compute (double 
    precision) Bessel functions of first kind (J), bessel function of second 
    kind (Y), Hankel function of first kind (H1) and Hankel function of second 
    kind (H2); and their first derivative w.r.t. argument for REAL/COMPLEX 
    ORDER and REAL/COMPLEX ARGUMENT. 
  2.The implementation is based of 'Uniform Asymptotic Expansion of Bessel
    functions in terms of Airy functions' as described in 'Handbook of 
    Mathematical Functions' by Abramowitz and Stegun (1964).
  3.For the computation of complex valued Airy function, FORTRAN routines of 
    Amos are used. These are available at www.netlib.org  
  4.The emphasis is on the utility of the routines for large (complex) order
    and large argument. 
  5.Caution: Routines show numerical instabilities for the case when the 
    absolute value of ratio of order to argument is close to 1.  

  * Please report the bugs in the code to  k.r.hiremath@ieee.org

    Copyright (C) <2004>  <Kirankumar R. Hiremath>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public
    License along with this library; if not, write to the
    Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA  02111-1307, USA.

*/

/* 
  Error codes:

  KODE = 1 => without scaling
  KODE = 2 => with scaling

  Error codes:
  IERR =  0 => :-) Success
  IERR = 11 => situation beyond scope of routines
  IERR = 12 => division by zero
  IERR =  5 => no computation, algorithm termination condition not met
  IERR =  4 => |z| too large. no computation.
  IERR =  3 => |z| too large. ans may wrong.
  IERR =  2 => overflow. no computation. Re(\zeta) too large for KODE = 1
  IERR =  1 => inout error

  Underflow indicator (in Airy function calculations): 
  NZ   = 0  => Normal return
  NZ   = 1   , AI=CMPLX(0.0D0,0.0D0) DUE TO UNDERFLOW IN
                              -PI/3.LT.ARG(Z).LT.PI/3 ON KODE=1
*/

#include <iostream>
#include <complex>
#include <cmath>


#define Pi M_PI   //macro definition for Pi
#define nan sqrt(-1.0)   // Not-a-Number

using namespace std;

void complex_bessel_error( char *s);

extern complex<double> BesselJ (complex<double> order, complex<double> argument, int KODE, int *NZ, int *IERR);
extern complex<double> BesselY (complex<double> order, complex<double> argument, int KODE, int *NZ, int *IERR);
extern complex<double> DBesselJ (complex<double> order, complex<double> argument,int KODE, int *NZ, int *IERR);
extern complex<double> DBesselY (complex<double> order, complex<double> argument,int KODE, int *NZ, int *IERR);
extern complex<double> HankelH1(complex<double> order, complex<double> argument, int KODE, int *NZ, int *IERR);
extern complex<double> HankelH2(complex<double> order, complex<double> argument, int KODE, int *NZ, int *IERR);
extern complex<double> DHankelH1(complex<double> order, complex<double> argument, int KODE, int *NZ, int *IERR);
extern complex<double> DHankelH2(complex<double> order, complex<double> argument, int KODE, int *NZ, int *IERR);
